<?php
echo $this->Html->css('jquery-ui');
echo $this->Html->css('ui.jqgrid');

echo $this->Html->script('grid.locale-en');
echo $this->Html->script('jquery.jqGrid.min');
?>
<div class="users index">
    <script type="text/javascript">
        jQuery(document).ready(function(){
            jQuery("#list").jqGrid(
            {
                url:'<?php echo $this->Html->url(array("controller" => "users", "action" => "index", "ajax" => true)); ?>',
                datatype: "json",
                mtype: "GET",
                colNames:['First Name','Last Name','Email','Mobile','City','Actions'],
                colModel:[
                    {name:'firstname',index:'firstname', width:30, search:true},
                    {name:'lastname',index:'lastname', width:30, search:true},
                    {name:'email',index:'email1', width:30, search:true},
                    {name:'mobile',index:'mobilephone', width:30, search:true},
                    {name:'city',index:'city', width:30, search:true, sortable:false},
                    {name:'actions',width:50,sortable:false,align:"center",search:false}
                ],
                rowNum:10,
                rowList:[10,20,30],
                pager: jQuery('#pager'),
                sortname: 'firstname',
                viewrecords: true,
                sortorder: "asc",
                caption:"Users",
                height:"auto",
                autowidth: true,
                navigator:true
            });
            jQuery("#list").navGrid("#pager",{edit:false,add:false,del:false,search:false});
            jQuery("#list").jqGrid('filterToolbar');
        })
    </script>
    <h3><?php __('Users'); ?></h3>
    <?php
    echo $this->Html->link('Upload Users CSV File', 'javascript:void(0)', array(
        'class' => 'linkbutton',
        'style' => 'margin-bottom:10px;',
        'onclick' => '$(\'#csvuploadform\').toggle(\'slow\')',
        'escape' => false
    ));
    ?>
    <br/>
    <div id="csvuploadform" style="display:none;">
        <?php
        echo $this->Form->create('User', array(
            'url' => array(
                'controller' => 'users',
                'action' => 'uploadcsv'
            ),
            'enctype' => 'multipart/form-data'
        ));
        echo $this->Form->input('csvfile', array(
            'type' => 'file',
            'label' => 'CSV File'
        ));
        echo $this->Form->end('Upload');
        ?>
    </div>
    <br/>
    <table id="list" style="height:auto;"></table>
    <div id="pager"></div>
</div>